﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using BLL;
using IFactory;

public partial class Month_QuarterResolveForMonth : System.Web.UI.Page
{
    QuarterPlanDetailManager dllQuarterPlanDetail = new QuarterPlanDetailManager();
    IBussinessLogic dllQuarterPlan = new QuarterPlanofManager();
    Authentication dllAuthentication = new Authentication();
    DataTable _quarterPlanTable = new DataTable();
    protected void Page_Load(object sender, EventArgs e)
    {
        dllAuthentication.isLogin();
        if (!IsPostBack)
        {
            object[] _valueQuarterPlanId = new object[1];
            _valueQuarterPlanId[0] = Utility.HttpHelp.getParamsInt("_quarterPlanId");
            _quarterPlanTable = dllQuarterPlan.get(QuarterPlanofManager.field.QuarterPlanId.ToString(), _valueQuarterPlanId);
            if (_quarterPlanTable.Rows.Count > 0)
            {
                this.txtMasterDepartment.Text = _quarterPlanTable.Rows[0]["MasterDepartment"].ToString();
            }
            bindQuarterPlanGridView();
            this.txtQuarterPlanSortId.Value = Utility.HttpHelp.getParamsInt("_quarterPlanSortId") + "." + this.gdvQuarterPlanResolve.Rows.Count;
            //bindQuarterPlan();
        }
    }


    /// <summary>
    /// 绑定空记录表头GridView
    /// </summary>
    /// <author>grokyao</author>
    /// <date>2009-2-16</date>
    void bindQuarterPlan()
    {
        DataTable _quareterPlan = createDataTable();
        DataRow dr = _quareterPlan.NewRow();
        _quareterPlan.Rows.Add(dr);
        this.gdvQuarterPlanResolve.DataSource = _quareterPlan;
        this.gdvQuarterPlanResolve.DataBind();
        //隐藏首行，只保留表头
        this.gdvQuarterPlanResolve.Rows[0].Visible = false;
    }


    /// <summary>
    /// 绑定年分解GridView
    /// </summary>
    /// <author>grokyao</author>
    /// <date>2009-2-16</date>
    void bindQuarterPlanGridView()
    {
        object[] _value = new object[1];
        _value[0] = Utility.HttpHelp.getParamsString("_quarterPlanId");
        DataTable _quarterPlan = dllQuarterPlanDetail.get(QuarterPlanDetailManager.field.QuarterPlanId.ToString(), _value);
        DataRow dr = _quarterPlan.NewRow();
        _quarterPlan.Rows.InsertAt(dr, 0);
        DataView dv = new DataView(_quarterPlan);
        dv.Sort = "QuarterDetailPlanId";
        this.gdvQuarterPlanResolve.DataSource = dv;
        this.gdvQuarterPlanResolve.DataBind();
        //隐藏首行，只保留表头
        this.gdvQuarterPlanResolve.Rows[0].Visible = false;
        for (int i = 0; i < this.gdvQuarterPlanResolve.Rows.Count; i++)
        {
            string _Lengthstart = this.gdvQuarterPlanResolve.Rows[i].Cells[2].Text;
            string _Lengthend = this.gdvQuarterPlanResolve.Rows[i].Cells[3].Text;

            if (_Lengthstart.Length > 9)
            {
                _Lengthstart = _Lengthstart.Substring(0, 9);//截取字符串，从左边截取10个字符串
                this.gdvQuarterPlanResolve.Rows[i].Cells[2].Text = _Lengthstart;
            }
            if (_Lengthend.Length > 9)
            {
                _Lengthend = _Lengthend.Substring(0, 9);//截取字符串，从左边截取10个字符串
                this.gdvQuarterPlanResolve.Rows[i].Cells[3].Text = _Lengthend;
            }
        }
    }

    /// <summary>
    /// 创建空DataTable用于绑定GridView
    /// </summary>
    /// <author>grokyao</author>
    /// <date>2009-2-16</date>
    DataTable createDataTable()
    {
        DataTable _dataTable = new DataTable();
        _dataTable.Columns.Add("QuarterDetailPlanId");
        _dataTable.Columns.Add("StartTime");
        _dataTable.Columns.Add("CompleteTime");
        _dataTable.Columns.Add("WorkItem");
        _dataTable.Columns.Add("MasterDepartment");
        _dataTable.Columns.Add("MasterPeople");
        _dataTable.Columns.Add("SlaveDepartment");
        _dataTable.Columns.Add("SlaveDepartmentDuty");
        _dataTable.Columns.Add("EvaluatePeople");
        _dataTable.Columns.Add("Remart");
        _dataTable.Columns.Add("Id");
        _dataTable.Columns.Add("QuarterPlanId");
        return _dataTable;
    }

    /// <summary>
    /// GridView删除事件
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    /// <author>grokyao</author>
    /// <date>2009-2-17</date>
    protected void btnDel_Click(object sender, EventArgs e)
    {
        DataTable _quarterPlan = createDataTable();
        //获取GridView当前内容导入DataTable
        for (int i = 0; i < this.gdvQuarterPlanResolve.Rows.Count; i++)
        {
            DataRow _drGridView = _quarterPlan.NewRow();
            _drGridView["QuarterDetailPlanId"] = this.gdvQuarterPlanResolve.Rows[i].Cells[1].Text.ToString();
            _drGridView["StartTime"] = this.gdvQuarterPlanResolve.Rows[i].Cells[2].Text.ToString();
            _drGridView["CompleteTime"] = this.gdvQuarterPlanResolve.Rows[i].Cells[3].Text.ToString();
            _drGridView["WorkItem"] = this.gdvQuarterPlanResolve.Rows[i].Cells[4].Text.ToString();
            _drGridView["MasterDepartment"] = this.gdvQuarterPlanResolve.Rows[i].Cells[5].Text.ToString();
            _drGridView["MasterPeople"] = this.gdvQuarterPlanResolve.Rows[i].Cells[6].Text.ToString();
            _drGridView["SlaveDepartment"] = this.gdvQuarterPlanResolve.Rows[i].Cells[7].Text.ToString();
            _drGridView["SlaveDepartmentDuty"] = this.gdvQuarterPlanResolve.Rows[i].Cells[8].Text.ToString();
            _drGridView["EvaluatePeople"] = this.gdvQuarterPlanResolve.Rows[i].Cells[9].Text.ToString();
            _drGridView["Remart"] = this.gdvQuarterPlanResolve.Rows[i].Cells[10].Text.ToString();

            #region 去除特殊符号如&nbsp;
            _drGridView["StartTime"] = _drGridView["StartTime"].ToString().Replace("&", "");
            _drGridView["StartTime"] = _drGridView["StartTime"].ToString().Replace("nbsp;", "");
            _drGridView["CompleteTime"] = _drGridView["CompleteTime"].ToString().Replace("&", "");
            _drGridView["CompleteTime"] = _drGridView["CompleteTime"].ToString().Replace("nbsp;", "");
            _drGridView["WorkItem"] = _drGridView["WorkItem"].ToString().Replace("&", "");
            _drGridView["WorkItem"] = _drGridView["WorkItem"].ToString().Replace("nbsp;", "");

            _drGridView["MasterDepartment"] = _drGridView["MasterDepartment"].ToString().Replace("&", "");
            _drGridView["MasterDepartment"] = _drGridView["MasterDepartment"].ToString().Replace("nbsp;", "");
            _drGridView["MasterPeople"] = _drGridView["MasterPeople"].ToString().Replace("&", "");
            _drGridView["MasterPeople"] = _drGridView["MasterPeople"].ToString().Replace("nbsp;", "");
            _drGridView["SlaveDepartment"] = _drGridView["SlaveDepartment"].ToString().Replace("&", "");
            _drGridView["SlaveDepartment"] = _drGridView["SlaveDepartment"].ToString().Replace("nbsp;", "");

            _drGridView["SlaveDepartmentDuty"] = _drGridView["SlaveDepartmentDuty"].ToString().Replace("&", "");
            _drGridView["SlaveDepartmentDuty"] = _drGridView["SlaveDepartmentDuty"].ToString().Replace("nbsp;", "");
            _drGridView["EvaluatePeople"] = _drGridView["EvaluatePeople"].ToString().Replace("&", "");
            _drGridView["EvaluatePeople"] = _drGridView["EvaluatePeople"].ToString().Replace("nbsp;", "");
            _drGridView["Remart"] = _drGridView["Remart"].ToString().Replace("&", "");
            _drGridView["Remart"] = _drGridView["Remart"].ToString().Replace("nbsp;", "");
            #endregion

            _quarterPlan.Rows.Add(_drGridView);
        }
        int _rowId = 0;
        Button bt = (Button)sender;//获得当前控件
        TableCell cell = (TableCell)bt.Parent;//得到所处的父单元格
        GridViewRow iRow = (GridViewRow)cell.Parent;//得到所处父单元行
        _rowId = iRow.RowIndex;//得到该行的索引
        if (_quarterPlan.Rows.Count > _rowId)
        {
            if (this.gdvQuarterPlanResolve.DataKeys[_rowId]["Id"].ToString().Length == 0 || this.gdvQuarterPlanResolve.DataKeys[_rowId]["Id"].ToString() == "&nbsp;")
            {
            }
            else
            {
                object[] _quarterPlanId = new object[1];
                _quarterPlanId[0] = Convert.ToInt32(this.gdvQuarterPlanResolve.DataKeys[_rowId]["QuarterPlanId"].ToString());
                DataTable _quarterPlanTable = dllQuarterPlan.get(QuarterPlanofManager.field.QuarterPlanId.ToString(), _quarterPlanId);
                if (_quarterPlanTable.Rows.Count > 0)
                {
                    if (Convert.ToInt32(_quarterPlanTable.Rows[0]["PlanSendState"].ToString()) == 0)
                    {
                        _quarterPlan.Rows.RemoveAt(_rowId);
                        object[] _value = new object[1];
                        _value[0] = Convert.ToInt32(this.gdvQuarterPlanResolve.DataKeys[_rowId]["Id"].ToString());
                        int result = dllQuarterPlanDetail.del(QuarterPlanDetailManager.field.Id.ToString(), _value);
                        if (result == 0)
                        {
                            Utility.Error.RedirectErrorPage("删除年分解未成功，请重试");
                        }
                    }
                    else
                    {
                        Utility.HttpHelp.alert("该年分解所属的年计划已提交，不可以删除！", Page);
                    }
                }
            }
        }
        this.gdvQuarterPlanResolve.DataSource = _quarterPlan;
        this.gdvQuarterPlanResolve.DataBind();
        this.gdvQuarterPlanResolve.Rows[0].Visible = false;
        this.txtQuarterPlanSortId.Value = Utility.HttpHelp.getParamsInt("_quarterPlanSortId") + "." + (Convert.ToInt32(this.gdvQuarterPlanResolve.Rows.Count));
    }



    /// <summary>
    /// 增加新行事件
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    /// <author>grokyao</author>
    /// <date>2009-2-17</date>
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        int _isnull = isNull();
        if (_isnull == 0)
        {
            Utility.HttpHelp.alert("请输入完整", Page);
        }
        else
        {
            if (Convert.ToDouble(this.txtQuarterPlanSortId.Value) == 0)
            {
                Utility.HttpHelp.alert("计划编号只能从1开始！", Page);
                return;
            }
            if (!verifyDate())
            {
                return;
            }
            if (this.txtMasterPeople.Value.Contains(","))
            {
                Utility.HttpHelp.alert("责任人不可为多人！", Page);
                return;
            }
            if (this.txtVerifyPeople.Value.Contains(","))
            {
                Utility.HttpHelp.alert("评估人不可为多人！", Page);
                return;
            }
            DataTable _quarterPlan = createDataTable();
            //获取GridView当前内容导入DataTable
            for (int i = 0; i < this.gdvQuarterPlanResolve.Rows.Count; i++)
            {
                DataRow _drGridView = _quarterPlan.NewRow();
                _drGridView["QuarterDetailPlanId"] = this.gdvQuarterPlanResolve.Rows[i].Cells[1].Text.ToString();
                _drGridView["StartTime"] = this.gdvQuarterPlanResolve.Rows[i].Cells[2].Text.ToString();
                _drGridView["CompleteTime"] = this.gdvQuarterPlanResolve.Rows[i].Cells[3].Text.ToString();
                _drGridView["WorkItem"] = this.gdvQuarterPlanResolve.Rows[i].Cells[4].Text.ToString();
                _drGridView["MasterDepartment"] = this.gdvQuarterPlanResolve.Rows[i].Cells[5].Text.ToString();
                _drGridView["MasterPeople"] = this.gdvQuarterPlanResolve.Rows[i].Cells[6].Text.ToString();
                _drGridView["SlaveDepartment"] = this.gdvQuarterPlanResolve.Rows[i].Cells[7].Text.ToString();
                _drGridView["SlaveDepartmentDuty"] = this.gdvQuarterPlanResolve.Rows[i].Cells[8].Text.ToString();
                _drGridView["EvaluatePeople"] = this.gdvQuarterPlanResolve.Rows[i].Cells[9].Text.ToString();
                _drGridView["Remart"] = this.gdvQuarterPlanResolve.Rows[i].Cells[10].Text.ToString();
                _drGridView["Id"] = this.gdvQuarterPlanResolve.DataKeys[i]["Id"].ToString();
                _drGridView["QuarterPlanId"] = this.gdvQuarterPlanResolve.DataKeys[i]["QuarterPlanId"].ToString();

                #region 去除特殊符号如&nbsp;
                _drGridView["QuarterDetailPlanId"] = _drGridView["QuarterDetailPlanId"].ToString().Replace("&", "");
                _drGridView["QuarterDetailPlanId"] = _drGridView["QuarterDetailPlanId"].ToString().Replace("nbsp;", "");
                _drGridView["QuarterPlanId"] = _drGridView["QuarterPlanId"].ToString().Replace("&", "");
                _drGridView["QuarterPlanId"] = _drGridView["QuarterPlanId"].ToString().Replace("nbsp;", "");
                _drGridView["Id"] = _drGridView["Id"].ToString().Replace("&", "");
                _drGridView["Id"] = _drGridView["Id"].ToString().Replace("nbsp;", "");
                _drGridView["StartTime"] = _drGridView["StartTime"].ToString().Replace("&", "");
                _drGridView["StartTime"] = _drGridView["StartTime"].ToString().Replace("nbsp;", "");
                _drGridView["CompleteTime"] = _drGridView["CompleteTime"].ToString().Replace("&", "");
                _drGridView["CompleteTime"] = _drGridView["CompleteTime"].ToString().Replace("nbsp;", "");
                _drGridView["WorkItem"] = _drGridView["WorkItem"].ToString().Replace("&", "");
                _drGridView["WorkItem"] = _drGridView["WorkItem"].ToString().Replace("nbsp;", "");

                _drGridView["MasterDepartment"] = _drGridView["MasterDepartment"].ToString().Replace("&", "");
                _drGridView["MasterDepartment"] = _drGridView["MasterDepartment"].ToString().Replace("nbsp;", "");
                _drGridView["MasterPeople"] = _drGridView["MasterPeople"].ToString().Replace("&", "");
                _drGridView["MasterPeople"] = _drGridView["MasterPeople"].ToString().Replace("nbsp;", "");
                _drGridView["SlaveDepartment"] = _drGridView["SlaveDepartment"].ToString().Replace("&", "");
                _drGridView["SlaveDepartment"] = _drGridView["SlaveDepartment"].ToString().Replace("nbsp;", "");

                _drGridView["SlaveDepartmentDuty"] = _drGridView["SlaveDepartmentDuty"].ToString().Replace("&", "");
                _drGridView["SlaveDepartmentDuty"] = _drGridView["SlaveDepartmentDuty"].ToString().Replace("nbsp;", "");
                _drGridView["EvaluatePeople"] = _drGridView["EvaluatePeople"].ToString().Replace("&", "");
                _drGridView["EvaluatePeople"] = _drGridView["EvaluatePeople"].ToString().Replace("nbsp;", "");
                _drGridView["Remart"] = _drGridView["Remart"].ToString().Replace("&", "");
                _drGridView["Remart"] = _drGridView["Remart"].ToString().Replace("nbsp;", "");
                #endregion

                _quarterPlan.Rows.Add(_drGridView);
            }
            //获取当前添加的内容
            DataRow _drTable = _quarterPlan.NewRow();
            _drTable["QuarterDetailPlanId"] = this.txtQuarterPlanSortId.Value;
            _drTable["StartTime"] = this.txtStartTime.Text.Trim();
            _drTable["CompleteTime"] = this.txtCompleteTime.Text.Trim();
            _drTable["WorkItem"] = this.txtWorkItem.Text;
            _drTable["MasterDepartment"] = this.txtMasterDepartment.Text.Trim();
            _drTable["MasterPeople"] = this.txtMasterPeople.Value.Trim();
            _drTable["SlaveDepartment"] = this.txtSlaveDepartment.Value.Trim();
            _drTable["SlaveDepartmentDuty"] = this.txtSlaveDepartmentDuty.Text.Trim();
            _drTable["EvaluatePeople"] = this.txtVerifyPeople.Value.Trim();
            _drTable["Remart"] = this.txtRemark.Text;
            _quarterPlan.Rows.Add(_drTable);
            this.gdvQuarterPlanResolve.DataSource = _quarterPlan;
            this.gdvQuarterPlanResolve.DataBind();
            //隐藏首行，只保留表头
            this.gdvQuarterPlanResolve.Rows[0].Visible = false;
        }

        #region 善后处理事件
        this.txtCompleteTime.Text = "";
        this.txtMasterPeople.Value = "";
        this.txtQuarterPlanSortId.Value = "";
        this.txtRemark.Text = "";
        this.txtSlaveDepartment.Value = "";
        this.txtSlaveDepartmentDuty.Text = "";
        this.txtStartTime.Text = "";
        this.txtVerifyPeople.Value = "";
        this.txtWorkItem.Text = "";

        #endregion

        this.txtQuarterPlanSortId.Value = Utility.HttpHelp.getParamsInt("_quarterPlanSortId") + "." + (Convert.ToInt32(this.gdvQuarterPlanResolve.Rows.Count));
    }




    /// <summary>
    /// 判断控件值是否为空
    /// </summary>
    /// <returns>空返回0，有值返回1</returns>
    /// <author>grokyao</author>
    /// <date>2009-2-17</date>
    int isNull()
    {
        #region 验证是否为空
        if (this.txtCompleteTime.Text.Length == 0)
        {
            return 0;
        }
        if (this.txtMasterPeople.Value.Length == 0)
        {
            return 0;
        }
        if (this.txtWorkItem.Text.Length == 0)
        {
            return 0;
        }
        if (this.txtSlaveDepartment.Value.Length == 0)
        {
            return 0;
        }
        if (this.txtSlaveDepartmentDuty.Text.Length < 18 && this.txtSlaveDepartment.Value != "独立完成")
        {
            return 0;
        }
        if (this.txtStartTime.Text.Length == 0)
        {
            return 0;
        }
        if (this.txtVerifyPeople.Value.Length == 0)
        {
            return 0;
        }
        return 1;
        #endregion
    }
    /// <summary>
    /// 时间验证
    /// </summary>
    bool verifyDate()
    {
        #region 必要验证判断
        //判断完成时间是否大于起始时间

        DateTime _startTime = Convert.ToDateTime(this.txtStartTime.Text.Trim());
        DateTime _endTime = Convert.ToDateTime(this.txtCompleteTime.Text.Trim());
        if (!dllAuthentication.IsEndTimeGreaterThanStartTime(_startTime, _endTime))
        {
            Utility.HttpHelp.alert("完成时间需要大于起始时间", Page);
            return false;
        }


        return true;
        #endregion
    }
    /// <summary>
    /// 返回事件
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    /// <author>grokyao</author>
    /// <date>2009-2-17</date>
    protected void btnOk_Click(object sender, EventArgs e)
    {
        Utility.HttpHelp.closeWindowNoFresh("QuarterPlanAdd.aspx", Page);
    }

    /// <summary>
    /// 保存年分解计划
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    /// <author>grokyao</author>
    /// <date>2009-2-17</date>
    protected void btnSave_Click(object sender, EventArgs e)
    {
        //用于记录年分解计划id的序号
        int _quarterPlanDetailId = 0;
        List<object[]> _valueList = new List<object[]>();
        object[] _valueQuarterPlanId = new object[1];
        _valueQuarterPlanId[0] = Utility.HttpHelp.getParamsInt("_quarterPlanId");
        _quarterPlanTable = dllQuarterPlan.get(QuarterPlanofManager.field.QuarterPlanId.ToString(), _valueQuarterPlanId);
        if (_quarterPlanTable.Rows.Count > 0)
        {
            //将选择好的年计划记录加入集合
            for (int i = 1; i < this.gdvQuarterPlanResolve.Rows.Count; i++)
            {
                CheckBox ckb = (CheckBox)this.gdvQuarterPlanResolve.Rows[i].Cells[0].FindControl("ckbSelect");
                if (ckb.Checked == true)
                {
                    if (this.gdvQuarterPlanResolve.DataKeys[i]["Id"].ToString().Length == 0 || this.gdvQuarterPlanResolve.DataKeys[i]["Id"].ToString() == "&nbsp;")
                    {
                        //循环一次自增1次
                        _quarterPlanDetailId++;
                        object[] _value = new object[15];
                        _value[0] = Utility.HttpHelp.getParamsString("_quarterPlanId");
                        _value[1] = this.gdvQuarterPlanResolve.Rows[i].Cells[1].Text;
                        _value[2] = Convert.ToDateTime(this.gdvQuarterPlanResolve.Rows[i].Cells[2].Text);
                        _value[3] = Convert.ToDateTime(this.gdvQuarterPlanResolve.Rows[i].Cells[3].Text);
                        _value[4] = this.gdvQuarterPlanResolve.Rows[i].Cells[4].Text;
                        _value[5] = _quarterPlanTable.Rows[0]["MasterDepartment"].ToString();
                        _value[6] = this.gdvQuarterPlanResolve.Rows[i].Cells[6].Text;
                        _value[7] = this.gdvQuarterPlanResolve.Rows[i].Cells[7].Text;
                        _value[8] = this.gdvQuarterPlanResolve.Rows[i].Cells[8].Text;
                        _value[9] = this.gdvQuarterPlanResolve.Rows[i].Cells[9].Text;
                        _value[10] = 0;
                        _value[11] = this.gdvQuarterPlanResolve.Rows[i].Cells[10].Text;
                        _value[12] = Convert.ToInt32(_quarterPlanTable.Rows[0]["QuarterDate"].ToString());
                        _value[13] = Convert.ToInt32(_quarterPlanTable.Rows[0]["VerifyCircuitId"].ToString());
                        _value[14] = _quarterPlanTable.Rows[0]["Sponsor"].ToString();
                        _valueList.Add(_value);
                    }
                }
            }
            if (_valueList.Count > 0)
            {
                int result = dllQuarterPlanDetail.addWithTransaction(_valueList);
                if (result == 0)
                {
                    Utility.HttpHelp.alert("至少选择一条你要保存的年分解计划！", Page);
                }
                else
                {
                    bindGridViewQuarterResolve(Utility.HttpHelp.getParamsString("_quarterPlanId"));
                    Utility.HttpHelp.closeWindowNoFresh("QuarterPlanDetail.aspx", Page);
                }
            }
        }
    }


    /// <summary>
    /// 绑定年分解计划GridView
    /// </summary>
    void bindGridViewQuarterResolve(string _quarterPlanId)
    {
        object[] _value = new object[1];
        _value[0] = _quarterPlanId;
        DataTable _quarterResolve = dllQuarterPlanDetail.get(QuarterPlanDetailManager.field.QuarterPlanId.ToString(), _value);
        this.gdvQuarterPlanResolve.DataSource = _quarterResolve;
        this.gdvQuarterPlanResolve.DataBind();
        for (int i = 0; i < this.gdvQuarterPlanResolve.Rows.Count; i++)
        {
            string _Lengthstart = this.gdvQuarterPlanResolve.Rows[i].Cells[2].Text;
            string _Lengthend = this.gdvQuarterPlanResolve.Rows[i].Cells[3].Text;

            if (_Lengthstart.Length > 9)
            {
                _Lengthstart = _Lengthstart.Substring(0, 9);//截取字符串，从左边截取10个字符串
                this.gdvQuarterPlanResolve.Rows[i].Cells[2].Text = _Lengthstart;
            }
            if (_Lengthend.Length > 9)
            {
                _Lengthend = _Lengthend.Substring(0, 9);//截取字符串，从左边截取10个字符串
                this.gdvQuarterPlanResolve.Rows[i].Cells[3].Text = _Lengthend;
            }
            wrapByComma(this.gdvQuarterPlanResolve, i, 5);
            wrapByComma(this.gdvQuarterPlanResolve, i, 6);
        }
    }

    /// <summary>
    /// 根据逗号换行事件
    /// </summary>
    void wrapByComma(GridView _gridView, int _rowIndex, int _cells)
    {
        string _content = _gridView.Rows[_rowIndex].Cells[_cells].Text;
        _gridView.Rows[_rowIndex].Cells[_cells].Text = _content.Replace("&lt;br&gt;", "<br>");
        //_gridView.Rows[_rowIndex].Cells[_cells].Text = _content.Replace("&gt;", ">");
        _gridView.Rows[_rowIndex].Cells[_cells].Text = _gridView.Rows[_rowIndex].Cells[_cells].Text.Replace(",", "<br>");


    }


    /// <summary>
    /// 全选事件
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void ckbAllSelect_CheckedChanged(object sender, EventArgs e)
    {
        if (this.ckbAllSelect.Checked == true)
        {
            for (int i = 0; i < this.gdvQuarterPlanResolve.Rows.Count; i++)
            {
                CheckBox _chk = ((CheckBox)this.gdvQuarterPlanResolve.Rows[i].Cells[0].FindControl("ckbSelect"));
                _chk.Checked = true;
            }
        }
        else
        {
            for (int i = 0; i < this.gdvQuarterPlanResolve.Rows.Count; i++)
            {
                CheckBox _chk = ((CheckBox)this.gdvQuarterPlanResolve.Rows[i].Cells[0].FindControl("ckbSelect"));
                _chk.Checked = false;
            }

        }
    }

}
